import React, { Component } from "react";

export default class FuntComponent extends Component {
  constructor(props) {
    super(props);

    this.selectVal = React.createRef();
    this.state = {
      color: "red"
    };
  }
  render() {
    const { color } = this.state;
    return (
      <div>
        <select
          ref={this.selectVal}
          onChange={() => {
            this.setState({ color: this.selectVal.current.value });
          }}
        >
          <option>red</option>
          <option>blue</option>
          <option>green</option>
        </select>
        {this.props.children(color)}
      </div>
    );
  }
}
